home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-13 | 1.3 KB | 48 lines | [TEXT/R*ch] |
- //RGBtoYUV
- //This is the RGBtoYUV routine before all the strange optimization was
- //applied. The final version is in the following listing.
-
- void RGBtoYUV(unsigned char *ra, unsigned char *ga,
- unsigned char *ba, unsigned char *ya,
- signed char *ua, signed char *va,
- unsigned long numpix, void *pd)
- {
- register signed32 index;
- register signed32 i2;
- unsigned32 i;
- register unsigned32 hi, lo_rg, lo;
- register unsigned char *yar = ya;
- register signed char *var = va;
- register rgb_yuv_data *p = pd;
-
- for(i=0; i<numpix; i++) {
- /* Compute indexes */
- index = ((*ra++)<<8)+(*ga++);
- i2 = *ba++;
-
- /* Get high and low word from the RG arrays */
- lo_rg = p->yuv_rg_l[index];
- hi = p->yuv_rg_h[index];
-
- /* Add high and low words from the B arrays */
- lo = lo_rg + p->yuv_b_l[i2];
- hi += p->yuv_b_h[i2];
-
- /* Test for carry */
- if (lo < lo_rg) {
- /* there was a carry! */
- hi++;
-
- /* Store results */
- *ua++ = hi;
- *yar++ = lo>>12L;
- *var++ = hi>>21L;
- } else {
- /* Store results */
- *ua++ = hi;
- *yar++ = lo>>12L;
- *var++ = hi>>21L;
- }
- }
- }
-